from flask import Flask, render_template


def create_app(storage):
    app = Flask(__name__)

    @app.route('/')
    def index():
        bonds = storage.query_all()
        return render_template('index.html', 
                            bonds=bonds,
                            columns=[
                                ('债券代码', 'bond_code'),
                                ('债券名称', 'bond_name'),
                                ('最新价', 'price'),
                                ('溢价率', 'premium_rate'),
                                ('成交量', 'volume')
                            ])

    return app